var str = "";
$.ajax({
    url:"/RuanJianKeShe/getAllTeachersInfo",
    type:"post",
    data:{
        "msg":"getAllTeachersInfo",
    },
    dataType:"json",
    success:function(data){
        showAllTeachers(data.allTeachersList);
    },
    error:function(){
        alert("fail");
    }
})
function showAllTeachers(data) {
    var str = "";
    for (var i = 0; i < data.length; i++) {
        str = "<tr><td>" + data[i].tno +  "</td><td>" +
            data[i].tname + "</td><td>" + data[i].tsex + "</td><td>" + data[i].tage +
            "</td><td>" + data[i].telephone + "</td><td>" + data[i].email +
            "</td><td>" + "<button onclick=\"updateHandle(this.value)\" id="+ data[i].tno +" value="+data[i].tno+">修改</button>" +
            "</td><td>" + "<button onclick=\"deleteHandle("+data[i].tno+")\">删除</button>" +"</td><td></td></tr>";
        $("#tab").append(str);
    }
}
updateHandle = function (value) {
    window.location.href="../../../html/manager/update/updateTeacherInfo.html?index="+value
}
deleteHandle = function (data) {
    $.ajax({
        url:"/RuanJianKeShe/delTeacherInfo",
        type:"post",
        data:{
            "msg":"delTeacherInfo",
            "tno":data
        },
        dataType:"json",
        success:function(success){
            alert(success)
        },
        error:function(){
            alert("fail");
        }
    })
    window.location.reload();
}
add = function () {
    window.location.href="../../../html/manager/add/addTeacherInfo.html"
}
